package vip.ifmm.lehouse.email.service;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.PropertySource;
import vip.ifmm.lehouse.email.service.consumer.EmailSenderConsumer;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

@SpringBootApplication
@PropertySource(value = "classpath:properties/constant.properties", encoding = "utf-8")
public class LehouseEmailServiceApplication {

    // 邮件发送消息消费者
    @Resource
    private EmailSenderConsumer emailSenderConsumer = null;

    public static void main(String[] args) {
        SpringApplication.run(LehouseEmailServiceApplication.class, args);
    }

    @PostConstruct
    public void init() {
        emailSenderConsumer.start();
    }

    // 销毁收尾
    @PreDestroy
    public void destroy() {
        emailSenderConsumer.shutdown();
    }
}
